package com.camel.base.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.camel.base.model.TbMockRequest;
import com.camel.base.model.TbMockResponse;
import com.camel.base.service.TbMockResponseService;
import com.camel.core.controller.BaseCommonController;
import com.camel.core.service.BaseCommonService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/mockRespon")
public class TbMockResponseController extends BaseCommonController<TbMockResponse> {

    @Resource
    private TbMockResponseService<TbMockResponse> service;

    @Override
    public boolean exist(TbMockResponse entity) {
        return service.count(new QueryWrapper<TbMockResponse>()
                .eq("req_id", entity.getReqId())
                .eq("smart_logic", StringUtils.isBlank(entity.getSmartLogic()) ? "" : entity.getSmartLogic())) > 0;
    }

    @Override
    public BaseCommonService<TbMockResponse> getiService() {
        return service;
    }

    @Override
    public String getMouduleName() {
        return "mock响应";
    }
}
